package com.kenyi.co.ui.video;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.aliyun.vodplayer.media.AliyunLocalSource;
import com.aliyun.vodplayer.media.IAliyunVodPlayer;
import com.aliyun.vodplayerview.utils.ScreenUtils;
import com.aliyun.vodplayerview.widget.AliyunVodPlayerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.util.Util;
import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.interfaces.OnItemClickListener;
import com.github.jdsjlzx.interfaces.OnNetWorkErrorListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.github.jdsjlzx.recyclerview.ProgressStyle;
import com.google.gson.Gson;
import com.kenyi.co.GlideApp;
import com.kenyi.co.R;
import com.kenyi.co.common.ui.BaseActivity;
import com.kenyi.co.common.utils.RouteUtils;
import com.kenyi.co.okhttp.OkHttpUtils;
import com.kenyi.co.okhttp.callback.StringCallback;
import com.kenyi.co.okhttp.utils.GsonResultok;
import com.kenyi.co.ui.login.RegisterActivity;
import com.kenyi.co.ui.video.adapter.VideoDetailAdapter;
import com.kenyi.co.utils.CommonUtils;
import com.kenyi.co.utils.GlideImageLoader;
import com.kenyi.co.utils.GlideRoundedCorners;
import com.kenyi.co.utils.LogU;
import com.kenyi.co.utils.NetConfig;
import com.kenyi.co.utils.SharepUtils;
import com.stay4it.banner.Banner;
import com.stay4it.banner.BannerConfig;
import com.stay4it.banner.Transformer;
import com.stay4it.banner.listener.OnBannerListener;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import com.umeng.socialize.shareboard.ShareBoardConfig;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import okhttp3.Call;

import static com.kenyi.co.utils.CommonUtils.isFastClick;


/**
 * 文章详情页
 */
public class VideoDetailActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "VideoDetailActivity";
    private TextView tv_video_dec, tv_vedio_title, tv_video_detail, tv_video_ad_title, tv_video_header_2;
    private TextView tv_video_sc;
    private Banner lunbo;
    private Banner footerlunbo;
    private RelativeLayout li_home_vier;
    private RelativeLayout li_home_vier2;
    private LinearLayout li_video_ad_1, li_video_ad_2, li_video_ad_3, li_video_sc,li_video_share;
    private TextView tv_video_ad_1, tv_video_ad_2, tv_video_ad_3, tv_video_header_1, tv_video_ad_title2;
    private TextView tv_look;
    private ImageView iv_video_ad_1, iv_video_ad_2, iv_video_ad_3, iv_video_sc;
    private ImageView iv_video_header_ad_1, iv_video_header_ad_2, iv_video_header_ad_3;
    private RelativeLayout re_header_ad_1, re_header_ad_2, re_header_ad_3;
    private AliyunVodPlayerView mAliyunVodPlayerView = null;
    private String id;
    private int time;
    private VideoDetailBean packlist;
    private ImageView iv_video_back;
    private List<VideoDetailBean.DatasBean.AdPositionBean.VideoAdBean> itemListad;
    private LinearLayout li_ad;
    private LinearLayout adView;
    private LinearLayout footeradView;
    private float density;
    private Timer mTimer;
    private TimerTask mTimerTask;
    private LRecyclerViewAdapter mLRecyclerViewAdapter = null;
    private LRecyclerView mRecyclerView = null;

    private VideoDetailAdapter mDataAdapter = null;
    private Boolean AutoPlay = false;
    private Boolean is_sc = false;
    private String avid = "0";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_detail);
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();

        if (bundle != null && bundle.containsKey("id")) {
            id = bundle.getString("id");
        }

        initView();
        mRecyclerView = (LRecyclerView) findViewById(R.id.list);

        mDataAdapter = new VideoDetailAdapter(this);
        mLRecyclerViewAdapter = new LRecyclerViewAdapter(mDataAdapter);
        mRecyclerView.setAdapter(mLRecyclerViewAdapter);
        DividerDecoration divider = new DividerDecoration.Builder(this)
                .setHeight(R.dimen.common_30dp)
                .setPadding(R.dimen.default_divider_padding_10)
                .setColorResource(R.color.white)
                .build();
        mRecyclerView.addItemDecoration(divider);
        mRecyclerView.setPullRefreshEnabled(false);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setRefreshProgressStyle(ProgressStyle.LineSpinFadeLoader);
        mRecyclerView.setArrowImageView(R.drawable.ic_pulltorefresh_arrow);
        mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallSpinFadeLoader);
        adView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.video_detail_header, null);
        tv_vedio_title = adView.findViewById(R.id.tv_vedio_title);
        tv_video_sc = adView.findViewById(R.id.tv_video_sc);
        tv_video_dec = adView.findViewById(R.id.tv_video_dec);
        tv_video_header_1 = adView.findViewById(R.id.tv_video_header_1);
        li_video_sc = adView.findViewById(R.id.li_video_sc);
        li_video_share = adView.findViewById(R.id.li_video_share);
        iv_video_sc = adView.findViewById(R.id.iv_video_sc);
        tv_look = adView.findViewById(R.id.tv_look);
        tv_video_detail = adView.findViewById(R.id.tv_video_detail);
        tv_video_ad_title = adView.findViewById(R.id.tv_video_ad_title);
        lunbo = (Banner) adView.findViewById(R.id.banner);
        li_home_vier = (RelativeLayout) adView.findViewById(R.id.li_home_vier);
        ViewGroup.LayoutParams vParams = li_home_vier.getLayoutParams();
        density = getResources().getDisplayMetrics().density;//dp转px
        int biankaung = (int) (32 * density + 0.5);
        vParams.height = (int) ((CommonUtils.getMobileWidth(this) - biankaung) * 0.47);
        vParams.width = (int) (CommonUtils.getMobileWidth(this) - biankaung);
        li_home_vier.setLayoutParams(vParams);
        li_video_sc.setOnClickListener(this);
        tv_video_detail.setOnClickListener(this);
        li_video_share.setOnClickListener(this);
        footeradView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.video_detail_footer, null);
        tv_video_header_2 = footeradView.findViewById(R.id.tv_video_header_1);
        footerlunbo = (Banner) footeradView.findViewById(R.id.banner);
        tv_video_ad_title2 = footeradView.findViewById(R.id.tv_video_ad_title);
        li_home_vier2 = (RelativeLayout) footeradView.findViewById(R.id.li_home_vier);
        ViewGroup.LayoutParams vParams2 = li_home_vier2.getLayoutParams();
        vParams2.height = (int) ((CommonUtils.getMobileWidth(this) - biankaung) * 0.47);
        vParams2.width = (int) (CommonUtils.getMobileWidth(this) - biankaung);
        li_home_vier2.setLayoutParams(vParams2);
        mLRecyclerViewAdapter.addFooterView(footeradView);
        mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
        initAliyunPlayerView();

        getVideoDetail();
        //是否禁用自动加载更多功能,false为禁用, 默认开启自动加载更多功能
        mRecyclerView.setLoadMoreEnabled(true);
        mLRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

                VideoDetailBean.DatasBean.RecommendBean item = mDataAdapter.getDataList().get(position);
                if ("0".equals(item.getType())) {
                    if (!isFastClick()) {
                        return;
                    }
                    Intent metags = new Intent(VideoDetailActivity.this, VideoDetailActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putString("id", item.getId() + "");
                    bundle.putString("is_again", "1");
                    metags.putExtras(bundle);
                    startActivity(metags);

                    finish();

                } else {
                    Map<String, String> params = new HashMap<>();
                    params.put("title", item.getAds().get(0).getTitle());
                    params.put("articleId", id);
                    params.put("url2", item.getAds().get(0).getUrl2());
                    params.put("advid", item.getAds().get(0).getId());
                    params.put("adPosition", 4 + "");
                    params.put("pageName", "VideoDetailActivity");
//                            RouteUtils.Route(VideoDetailActivity.this, itemListad.get(i).getUrl(), itemListad.get(i).getTitle());
                    RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, item.getAds().get(0).getUrl(), params);

//                    RouteUtils.Route(VideoDetailActivity.this, item.getAds().get(0).getUrl(), item.getAds().get(0).getTitle());
                }

            }
        });

        //设置底部加载文字提示
        mRecyclerView.setFooterViewHint("努力加载中", "已经加载全部", "网络不给力啊，点击再试一次吧");
        mRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {
            @Override
            public void reload() {

            }
        });
        mRecyclerView.refresh();

        getAddFoot();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        if ("1".equals(SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.IS_SC))) {
            iv_video_sc.setImageResource(R.drawable.iv_video_sc_ok);

            tv_video_sc.setText("已收藏");
            is_sc = true;
        } else {
            iv_video_sc.setImageResource(R.drawable.iv_video_sc);
            tv_video_sc.setText("收藏");

            is_sc = false;
        }

        timeUtils(1);
        if (AutoPlay) {

            getCollect();
        }
    }

    protected void setStatusBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().setStatusBarColor(getResources().getColor(R.color.main_text_000000));//设置状态栏颜色
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//实现状态栏图标和文字颜色为暗色
        }
    }

    private void initView() {
//        setStatusBar();
        li_video_ad_1 = findViewById(R.id.li_video_ad_1);
        li_video_ad_2 = findViewById(R.id.li_video_ad_2);
        li_video_ad_3 = findViewById(R.id.li_video_ad_3);
        tv_video_ad_1 = findViewById(R.id.tv_video_ad_1);
        tv_video_ad_2 = findViewById(R.id.tv_video_ad_2);
        tv_video_ad_3 = findViewById(R.id.tv_video_ad_3);
        iv_video_ad_1 = findViewById(R.id.iv_video_ad_1);
        iv_video_ad_2 = findViewById(R.id.iv_video_ad_2);
        iv_video_ad_3 = findViewById(R.id.iv_video_ad_3);
        li_ad = findViewById(R.id.li_ad);
        iv_video_header_ad_1 = findViewById(R.id.iv_video_header_ad_1);
        iv_video_header_ad_2 = findViewById(R.id.iv_video_header_ad_2);
        iv_video_header_ad_3 = findViewById(R.id.iv_video_header_ad_3);
        re_header_ad_1 = findViewById(R.id.re_header_ad_1);
        re_header_ad_2 = findViewById(R.id.re_header_ad_2);
        re_header_ad_3 = findViewById(R.id.re_header_ad_3);
        iv_video_back = findViewById(R.id.iv_video_back);
        mAliyunVodPlayerView = (AliyunVodPlayerView) findViewById(R.id.video_view);
        li_video_ad_1.setOnClickListener(this);
        li_video_ad_2.setOnClickListener(this);
        li_video_ad_3.setOnClickListener(this);
        iv_video_header_ad_1.setOnClickListener(this);
        iv_video_header_ad_2.setOnClickListener(this);
        iv_video_header_ad_3.setOnClickListener(this);
        iv_video_back.setOnClickListener(this);

    }

    private void initAliyunPlayerView() {

        //保持屏幕敞亮
        mAliyunVodPlayerView.setKeepScreenOn(true);
        mAliyunVodPlayerView.setTheme(AliyunVodPlayerView.Theme.Blue);
        mAliyunVodPlayerView.setOnPreparedListener(new MyPrepareListener(this));
        mAliyunVodPlayerView.setOnCompletionListener(new MyCompletionListener(this));
        mAliyunVodPlayerView.setOnStoppedListener(new MyStoppedListener(this));
        mAliyunVodPlayerView.setOnPlayStateBtnClickListener(new MyPlayStateBtnClickListener(this));
        mAliyunVodPlayerView.setOnSeekCompleteListener(new MySeekCompleteListener(this));
        mAliyunVodPlayerView.setOnSeekStartListener(new MySeekStartListener(this));
        mAliyunVodPlayerView.enableNativeLog();


    }

    @Override
    protected void onStop() {
        super.onStop();
        if (mAliyunVodPlayerView != null) {
            mAliyunVodPlayerView.onStop();
        }
    }

    private static class MySeekCompleteListener implements IAliyunVodPlayer.OnSeekCompleteListener {
        WeakReference<VideoDetailActivity> weakReference;

        MySeekCompleteListener(VideoDetailActivity activity) {
            weakReference = new WeakReference<>(activity);
        }

        @Override
        public void onSeekComplete() {
            VideoDetailActivity activity = weakReference.get();
            if (activity != null) {
                activity.onSeekComplete();
            }
        }
    }

    private void onSeekComplete() {

    }

    private static class MySeekStartListener implements AliyunVodPlayerView.OnSeekStartListener {
        WeakReference<VideoDetailActivity> weakReference;

        MySeekStartListener(VideoDetailActivity activity) {
            weakReference = new WeakReference<>(activity);
        }

        @Override
        public void onSeekStart() {
            VideoDetailActivity activity = weakReference.get();
            if (activity != null) {
                activity.onSeekStart();
            }
        }
    }

    private void onSeekStart() {

    }


    private static class MyPlayStateBtnClickListener implements AliyunVodPlayerView.OnPlayStateBtnClickListener {
        WeakReference<VideoDetailActivity> weakReference;

        MyPlayStateBtnClickListener(VideoDetailActivity activity) {
            weakReference = new WeakReference<>(activity);
        }

        @Override
        public void onPlayBtnClick(IAliyunVodPlayer.PlayerState playerState) {
            VideoDetailActivity activity = weakReference.get();
            if (activity != null) {

//                activity.onPlayStateSwitch(playerState);
            }

        }
    }

    private static class MyPrepareListener implements IAliyunVodPlayer.OnPreparedListener {

        private WeakReference<VideoDetailActivity> activityWeakReference;

        public MyPrepareListener(VideoDetailActivity skinActivity) {
            activityWeakReference = new WeakReference<VideoDetailActivity>(skinActivity);
        }

        @Override
        public void onPrepared() {
            VideoDetailActivity activity = activityWeakReference.get();
            if (activity != null) {
                activity.onPrepared();
            }
        }
    }

    private static class MyCompletionListener implements IAliyunVodPlayer.OnCompletionListener {

        private WeakReference<VideoDetailActivity> activityWeakReference;

        public MyCompletionListener(VideoDetailActivity skinActivity) {
            activityWeakReference = new WeakReference<VideoDetailActivity>(skinActivity);
        }

        @Override
        public void onCompletion() {

            VideoDetailActivity activity = activityWeakReference.get();
            if (activity != null) {
                activity.onCompletion();
            }
        }
    }

    private void onCompletion() {
        mAliyunVodPlayerView.setPlayState();
//        FixedToastUtils.show(PlayActivity.this.getApplicationContext(), R.string.toast_play_compleion);
        // 当前视频播放结束, 播放下一个视频
    }


    private static class MyStoppedListener implements IAliyunVodPlayer.OnStoppedListener {

        private WeakReference<VideoDetailActivity> activityWeakReference;

        public MyStoppedListener(VideoDetailActivity skinActivity) {
            activityWeakReference = new WeakReference<VideoDetailActivity>(skinActivity);
        }

        @Override
        public void onStopped() {

            VideoDetailActivity activity = activityWeakReference.get();
            if (activity != null) {
//                activity.onStopped();
            }
        }
    }


    private void onPrepared() {

        if (mAliyunVodPlayerView != null) {
            mAliyunVodPlayerView.start();

        }
        timeUtils(1);
//        mAliyunVodPlayerView.setPlayState1();
//        FixedToastUtils.show(PlayActivity.this.getApplicationContext(), R.string.toast_prepare_success);
    }

    @Override
    public void onResume() {
        super.onResume();
        updatePlayerViewMode();
        if (mAliyunVodPlayerView != null) {
            mAliyunVodPlayerView.onResume();
        }
        MobclickAgent.onPageStart("设置页面");
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mTimer != null) {
            mTimer.cancel();
            mTimer = null;
        }
        if (mAliyunVodPlayerView != null) {
            mAliyunVodPlayerView.onStop();
        }
        MobclickAgent.onPageEnd("设置页面");
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mTimer != null) {
            mTimer.cancel();
            mTimer = null;
        }
        if (mAliyunVodPlayerView != null) {
            mAliyunVodPlayerView.onDestroy();
        }
        UMShareAPI.get(this).release();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);


        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);


    }

    private void initPopupWindow() {
        ShareBoardConfig config = new ShareBoardConfig();//新建ShareBoardConfig
        config.setMenuItemBackgroundShape(ShareBoardConfig.BG_SHAPE_CIRCULAR, 5);
        config.setCancelButtonVisibility(true);
        config.setTitleVisibility(false);
        config.setIndicatorVisibility(false);
        config.setShareboardBackgroundColor(Color.WHITE);
        config.setCancelButtonText("取消");
//        config.setShareboardBackgroundColor(R.color.white);
        UMImage image = new UMImage(VideoDetailActivity.this, packlist.getDatas().getArticle().getShare().getImg());
        UMWeb web = new UMWeb(packlist.getDatas().getArticle().getShare().getUrl());
        web.setTitle(packlist.getDatas().getArticle().getShare().getTitle());//标题
        web.setThumb(image);  //缩略图
        web.setDescription(packlist.getDatas().getArticle().getShare().getDesc());//描述
        ShareAction mShareAction;
        mShareAction = new ShareAction(this)
                .withMedia(web)
                .setDisplayList(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE)
//                .addButton("微信好友","umeng_sharebutton_custom","umeng_socialize_wechat","umeng_socialize_wechat")
                .setCallback(umShareListener);
        mShareAction.open(config);//传入分享面板中

    }

    private UMShareListener umShareListener = new UMShareListener() {
        @Override
        public void onStart(SHARE_MEDIA share_media) {
            if (UMShareAPI.get(VideoDetailActivity.this).isInstall(VideoDetailActivity.this, share_media)) {
                Toast.makeText(VideoDetailActivity.this, "准备分享...", Toast.LENGTH_SHORT).show();
            } else {

                Toast.makeText(VideoDetailActivity.this, "未安装微信", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onResult(SHARE_MEDIA platform) {
            Toast.makeText(VideoDetailActivity.this, " 分享成功啦", Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {

            Toast.makeText(VideoDetailActivity.this, " 分享失败啦", Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {
            Toast.makeText(VideoDetailActivity.this, " 分享取消了", Toast.LENGTH_SHORT).show();

        }
    };

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_video_header_ad_1:
                for (int i = 0; i < itemListad.size(); i++) {

                    if ("left".equals(itemListad.get(i).getPosition())) {
                        if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                            Map<String, String> params = new HashMap<>();
                            params.put("title", itemListad.get(i).getTitle());
                            params.put("articleId", id);
                            params.put("url2", itemListad.get(i).getUrl2());
                            params.put("advid", itemListad.get(i).getId());
                            params.put("adPosition", 3 + "");
                            params.put("pageName", "VideoDetailActivity");
//                            RouteUtils.Route(VideoDetailActivity.this, itemListad.get(i).getUrl(), itemListad.get(i).getTitle());
                            RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, itemListad.get(i).getUrl(), params);
                        }

                    }
                }


                break;
            case R.id.iv_video_header_ad_2:
                for (int i = 0; i < itemListad.size(); i++) {
                    if ("center".equals(itemListad.get(i).getPosition())) {
                        if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                            Map<String, String> params = new HashMap<>();
                            params.put("title", itemListad.get(i).getTitle());
                            params.put("articleId", id);
                            params.put("url2", itemListad.get(i).getUrl2());
                            params.put("advid", itemListad.get(i).getId());
                            params.put("adPosition", 3 + "");
                            params.put("pageName", "VideoDetailActivity");
//                            RouteUtils.Route(VideoDetailActivity.this, itemListad.get(i).getUrl(), itemListad.get(i).getTitle());
                            RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, itemListad.get(i).getUrl(), params);
                        }
                    }
                }


                break;
            case R.id.iv_video_header_ad_3:
                for (int i = 0; i < itemListad.size(); i++) {
                    if ("right".equals(itemListad.get(i).getPosition())) {
                        if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                            Map<String, String> params = new HashMap<>();
                            params.put("title", itemListad.get(i).getTitle());
                            params.put("articleId", id);
                            params.put("url2", itemListad.get(i).getUrl2());
                            params.put("advid", itemListad.get(i).getId());
                            params.put("adPosition", 3 + "");
                            params.put("pageName", "VideoDetailActivity");
//                            RouteUtils.Route(VideoDetailActivity.this, itemListad.get(i).getUrl(), itemListad.get(i).getTitle());
                            RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, itemListad.get(i).getUrl(), params);
                        }
                    }
                }

                break;
            case R.id.li_video_sc:
                if ("1".equals(SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_IS_LOGIN))) {
                    if (is_sc) {
                        getDeleteCollectActicles(id);
                    } else {
                        getCollect();
                    }

                } else {
                    AutoPlay = true;
                    Intent intentlogin = new Intent(VideoDetailActivity.this, RegisterActivity.class);
                    Bundle bundlelogin = new Bundle();
                    bundlelogin.putString("isfinish", "1");
                    intentlogin.putExtras(bundlelogin);

                    startActivity(intentlogin);
                    overridePendingTransition(R.anim.slide_out_to_top, R.anim.slide_out_to_bottom);
                }


                break;
            case R.id.tv_video_detail:

                Intent metags = new Intent(VideoDetailActivity.this, VideoDetailContentActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("id", id + "");
//                bundle.putString("id", "1907030516");
                metags.putExtras(bundle);

                startActivity(metags);
                break;
            case R.id.li_video_ad_1:
                Map<String, String> params = new HashMap<>();
                params.put("title", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(0).
                        getTitle());
                params.put("articleId", id);
                params.put("url2", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(0).getUrl2());
                params.put("advid", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(0).
                        getId());
                params.put("adPosition", 5 + "");
                params.put("pageName", "VideoDetailActivity");
                RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(0).
                        getUrl(), params);

                break;
            case R.id.li_video_ad_2:
                Map<String, String> params1 = new HashMap<>();
                params1.put("title", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(1).
                        getTitle());
                params1.put("articleId", id);
                params1.put("url2", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(1).getUrl2());
                params1.put("advid", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(1).
                        getId());
                params1.put("adPosition", 5 + "");
                params1.put("pageName", "VideoDetailActivity");
                RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(1).
                        getUrl(), params1);


                break;
            case R.id.li_video_ad_3:
                Map<String, String> params3 = new HashMap<>();
                params3.put("title", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(2).
                        getTitle());
                params3.put("articleId", id);
                params3.put("url2", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(2).getUrl2());
                params3.put("advid", packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(2).
                        getId());
                params3.put("adPosition", 5 + "");
                params3.put("pageName", "VideoDetailActivity");
                RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, packlist.getDatas().
                        getAdPosition().
                        getFloatLayerAd().
                        get(2).
                        getUrl(), params3);


                break;
            case R.id.iv_video_back:
//                finish();

                int orientation = getResources().getConfiguration().orientation;
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    finish();
                } else {
                    mAliyunVodPlayerView.setPlayPortroit();
                }
            case R.id.li_video_share:
//                finish();
                initPopupWindow();

                break;
        }

    }

    /**
     * 获取视频的详情
     */
    public void getVideoDetail() {

        final Map<String, String> params = new HashMap<>();

        params.put("id", "" + id);

        Map<String, String> headers = new HashMap<>();

        headers.put("Authorization", SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_TOKEN));
        String url = NetConfig.VIDEO_DETAIL;
        OkHttpUtils.get()
                .url(url)
                .params(params)
                .headers(headers)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {



                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Gson gson = new Gson();

                        int num = 0;
                        packlist = gson.fromJson(response, VideoDetailBean.class);
                        int code = packlist.getCode();
                        if (code == 200) {
                            tv_vedio_title.setText(packlist.getDatas().getArticle().getShowTitle());
                            tv_video_dec.setText(packlist.getDatas().getArticle().getDesc());
                            itemListad = new ArrayList<VideoDetailBean.DatasBean.AdPositionBean.VideoAdBean>();
                            itemListad = packlist.getDatas().getAdPosition().getVideoAd();


                            floatLayerad();
                            if (packlist.getDatas().getAdPosition().getFirstAd().size() > 0) {
                                initBanner(packlist.getDatas().getAdPosition().getFirstAd());
                                tv_video_header_1.setVisibility(View.VISIBLE);
                            } else {
                                li_home_vier.setVisibility(View.GONE);
                                tv_video_ad_title.setVisibility(View.GONE);
                                tv_video_header_1.setVisibility(View.GONE);
                                lunbo.setVisibility(View.GONE);


                            }
                            if (packlist.getDatas().getAdPosition().getArticleBottom().size() > 0) {
                                initBanner2(packlist.getDatas().getAdPosition().getArticleBottom());
                                tv_video_header_2.setVisibility(View.VISIBLE);
                            } else {
                                li_home_vier2.setVisibility(View.GONE);
                                tv_video_ad_title2.setVisibility(View.GONE);
                                footerlunbo.setVisibility(View.GONE);
                                tv_video_header_2.setVisibility(View.GONE);

                            }
                            tv_look.setVisibility(View.VISIBLE);
                            if (packlist.getDatas().getArticle().isIsFav()) {
                                iv_video_sc.setImageResource(R.drawable.iv_video_sc_ok);
                                SharepUtils.setString_info(VideoDetailActivity.this, "1", SharepUtils.IS_SC);
                                tv_video_sc.setText("已收藏");
                                is_sc = true;
                            } else {
                                iv_video_sc.setImageResource(R.drawable.iv_video_sc);
                                tv_video_sc.setText("收藏");
                                SharepUtils.setString_info(VideoDetailActivity.this, "0", SharepUtils.IS_SC);
                                is_sc = false;
                            }
                            List<VideoDetailBean.DatasBean.RecommendBean> itemList = new ArrayList<VideoDetailBean.DatasBean.RecommendBean>();
                            itemList = packlist.getDatas().getRecommend();
                            num = itemList.size();

                            mLRecyclerViewAdapter.addHeaderView(adView);
                            for (int i = 0; i < itemList.size(); i++) {
                                if ("0".equals(itemList.get(i).getType())) {

                                    itemList.get(i).setItemType(1);
                                } else {
                                    if (itemList.get(i).getAds().size() == 1) {
                                        if (itemList.get(i).getAds().get(0).getImgs().size() > 1) {

                                            itemList.get(i).setItemType(2);
                                        } else {
                                            int width = Integer.parseInt(itemList.get(i).getAds().get(0).getWidth());
                                            if (width > 200) {

                                                itemList.get(i).setItemType(4);
                                            } else {

                                                itemList.get(i).setItemType(3);
                                            }

                                        }
                                    } else if (itemList.get(i).getAds().size() > 1) {

                                        itemList.get(i).setItemType(5);
                                    }

                                }
                            }


                            mDataAdapter.addAll(itemList);
                            mRecyclerView.setVisibility(View.VISIBLE);
                            mRecyclerView.refreshComplete(num);
                            String url = packlist.getDatas().getArticle().getVideoUrl();
                            AliyunLocalSource.AliyunLocalSourceBuilder asb = new AliyunLocalSource.AliyunLocalSourceBuilder();
                            asb.setSource(url);

                            if ("1".equals(SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.VIDEO_ONE))) {
                                mAliyunVodPlayerView.setLocalSource(asb.build(), true);
                            } else {
                                mAliyunVodPlayerView.setLocalSource(asb.build(), false);
                            }

                        }


                    }
                });
    }

    /**
     * 收藏视频
     */
    public void getCollect() {

        Map<String, String> params = new HashMap<>();

        params.put("userId", "" + SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_USERID));
        params.put("articlesId", "" + id);

        Map<String, String> headers = new HashMap<>();

        headers.put("Content-Type", "application/json");
        headers.put("Authorization", SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_TOKEN));
        String url = NetConfig.APPUSER_COLLECT;
        OkHttpUtils.post()
                .url(url)
                .params(params)
                .headers(headers)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Gson gson = new Gson();

                        AutoPlay = false;
                        GsonResultok packlist1 = gson.fromJson(response, GsonResultok.class);
                        int code = packlist1.getCode();
                        if (code == 200) {
                            SharepUtils.setString_info(VideoDetailActivity.this, "1", SharepUtils.IS_SC);
                            is_sc = true;
                            tv_video_sc.setText("已收藏");
                            iv_video_sc.setImageResource(R.drawable.iv_video_sc_ok);

                        } else if (code == 401) {
                            is_sc = true;
                            SharepUtils.setString_info(VideoDetailActivity.this, "1", SharepUtils.IS_SC);
                            tv_video_sc.setText("已收藏");
                            iv_video_sc.setImageResource(R.drawable.iv_video_sc_ok);
                        }


                    }
                });
    }

    /**
     * 收藏视频
     */
    public void getAddFoot() {

        Map<String, String> params = new HashMap<>();

        params.put("userId", "" + SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_USERID));
        params.put("articlesId", "" + id);

        Map<String, String> headers = new HashMap<>();

        headers.put("Content-Type", "application/json");
        headers.put("Authorization", SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_TOKEN));
        String url = NetConfig.APPUSER_ADD_FOOTARTICLES;
        OkHttpUtils.post()
                .url(url)
                .params(params)
                .headers(headers)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Gson gson = new Gson();

                        GsonResultok packlist = gson.fromJson(response, GsonResultok.class);
                        int code = packlist.getCode();
                        if (code == 200) {

                        }


                    }
                });
    }

    private void floatLayerad() {
        if (packlist.getDatas().getAdPosition().getFloatLayerAd() != null) {
            if (packlist.getDatas().getAdPosition().getFloatLayerAd().size() == 0) {
                return;
            }
            try {
                if (Util.isOnMainThread() && mContext != null) {
                    if (packlist.getDatas().getAdPosition().getFloatLayerAd().get(0) != null) {
                        li_video_ad_1.setVisibility(View.VISIBLE);
                        tv_video_ad_1.setText(packlist.getDatas().getAdPosition().getFloatLayerAd().get(0).getTitle());
                        GlideApp.with(mContext)
                                .load(packlist.getDatas().getAdPosition().getFloatLayerAd().get(0).getImgs().get(0))
                                .into(iv_video_ad_1);
                    }
                    if (packlist.getDatas().getAdPosition().getFloatLayerAd().size() > 1 && packlist.getDatas().getAdPosition().getFloatLayerAd().get(1) != null) {
                        li_video_ad_2.setVisibility(View.VISIBLE);
                        tv_video_ad_2.setText(packlist.getDatas().getAdPosition().getFloatLayerAd().get(1).getTitle());
                        GlideApp.with(mContext)
                                .load(packlist.getDatas().getAdPosition().getFloatLayerAd().get(1).getImgs().get(0))
                                .into(iv_video_ad_2);
                    }
                    if (packlist.getDatas().getAdPosition().getFloatLayerAd().size() > 2 && packlist.getDatas().getAdPosition().getFloatLayerAd().get(2) != null) {
                        li_video_ad_3.setVisibility(View.VISIBLE);
                        tv_video_ad_3.setText(packlist.getDatas().getAdPosition().getFloatLayerAd().get(2).getTitle());
                        GlideApp.with(mContext)
                                .load(packlist.getDatas().getAdPosition().getFloatLayerAd().get(2).getImgs().get(0))
                                .into(iv_video_ad_3);
                    }
                }

            } catch (Exception e) {

            }

        }

    }

    /**
     * 初始化
     */
    private void initBanner(final List<VideoDetailBean.DatasBean.AdPositionBean.FirstAdBean> list) {
        tv_video_ad_title.setText(list.get(0).getTitle());
        lunbo.setDelayTime(3000)
                .setBannerAnimation(Transformer.DepthPage)
                .setImages(list)
                .setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
                .setIndicatorGravity(BannerConfig.CENTER)
                .setImageLoader(new GlideImageLoader() {
                    @Override
                    public void displayImage(Context context, Object path, ImageView imageView) {
                        VideoDetailBean.DatasBean.AdPositionBean.FirstAdBean bannerInfo = (VideoDetailBean.DatasBean.AdPositionBean.FirstAdBean) path;
                        try {
                            if (Util.isOnMainThread()) {
                                RequestOptions myOptions = new RequestOptions()
                                        .error(R.drawable.iv_bg_video_right)
                                        .fitCenter()
                                        .optionalTransform
                                                (new GlideRoundedCorners(CommonUtils.dip2px(context, 5)
                                                        , GlideRoundedCorners.CornerType.ALL));
                                Glide.with(context)
                                        .load(bannerInfo.getImgs().get(0))
                                        .apply(myOptions)
                                        .into(imageView);
                            }
                        } catch (Exception e) {
                        }

                    }
                }).start();

        lunbo.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                Map<String, String> params = new HashMap<>();


                params.put("title", list.get(position).getTitle());
                params.put("articleId", id);
                params.put("url2", list.get(position).getUrl2());
                params.put("advid", list.get(position).getId());
                params.put("adPosition", "7");
                params.put("pageName", "VideoDetailActivity");

                params.put("carrierName", CommonUtils.getOperator(VideoDetailActivity.this));
                RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, list.get(position).getUrl(), params);

//                RouteUtils.Route(VideoDetailActivity.this, list.get(position).getUrl(), list.get(position).getTitle());

            }
        });
    }

    /**
     * 初始化
     */
    private void initBanner2(final List<VideoDetailBean.DatasBean.AdPositionBean.ArticleBottomBean> list) {
        tv_video_ad_title2.setText(list.get(0).getTitle());
        footerlunbo.setDelayTime(3000)
                .setBannerAnimation(Transformer.DepthPage)
                .setImages(list)
                .setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
                .setIndicatorGravity(BannerConfig.CENTER)
                .setImageLoader(new GlideImageLoader() {
                    @Override
                    public void displayImage(Context context, Object path, ImageView imageView) {
                        VideoDetailBean.DatasBean.AdPositionBean.ArticleBottomBean bannerInfo = (VideoDetailBean.DatasBean.AdPositionBean.ArticleBottomBean) path;
                        try {
                            if (Util.isOnMainThread() && context != null) {
                                RequestOptions myOptions = new RequestOptions()
                                        .error(R.drawable.iv_bg_video_right)
                                        .fitCenter()
                                        .optionalTransform
                                                (new GlideRoundedCorners(CommonUtils.dip2px(context, 5)
                                                        , GlideRoundedCorners.CornerType.ALL));
                                Glide.with(context)
                                        .load(bannerInfo.getImgs().get(0))
                                        .apply(myOptions)
                                        .into(imageView);
                            }
                        } catch (Exception e) {
                        }

                    }
                }).start();

        footerlunbo.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
//                RouteUtils.Route(VideoDetailActivity.this, list.get(position).getUrl(), list.get(position).getTitle());

                Map<String, String> params = new HashMap<>();


                params.put("title", list.get(position).getTitle());
                params.put("articleId", id);
                params.put("url2", list.get(position).getUrl2());
                params.put("advid", list.get(position).getId());
                params.put("adPosition", 2 + "");
                params.put("pageName", "VideoDetailActivity");

                params.put("carrierName", CommonUtils.getOperator(VideoDetailActivity.this));
                RouteUtils.RoutebyAd(getApplicationContext(), VideoDetailActivity.this, list.get(position).getUrl(), params);

            }
        });
    }

    /**
     * 倒计时的管理
     */
    public void timeUtils(final int type) {
        if (mTimer != null) {
            mTimer.cancel();
            mTimer = null;
        }
        mTimer = new Timer();
        mTimerTask = new TimerTask() {
            Runnable updateUI = new Runnable() {
                @Override
                public void run() {
                    updateUIText(type);
                }
            };

            @Override
            public void run() {
                runOnUiThread(updateUI);
            }
        };
        mTimer.schedule(mTimerTask, 0, 1000);
    }

    /**
     * 处理文本的显示
     */
    public void updateUIText(int type) {

        switch (type) {
            case 1:

                time = mAliyunVodPlayerView.getCurrentPosition() / 1000;
                try {
                    for (int i = 0; i < itemListad.size(); i++) {

                        if ("center".equals(itemListad.get(i).getPosition())) {
                            if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                                re_header_ad_2.setVisibility(View.VISIBLE);
                                GlideApp.with(VideoDetailActivity.this)
                                        .load(itemListad.get(i).getImgs().get(0))
                                        .override((int) (itemListad.get(i).getWidth() * density), (int) (itemListad.get(i).getHeight() * density))
                                        .into(iv_video_header_ad_2);
                                if (avid.equals(itemListad.get(i).getId())) {

                                } else {
                                    Map<String, String> params = new HashMap<>();
                                    params.put("articleId", id);
                                    params.put("advid", itemListad.get(i).getId());
                                    params.put("pageName", "VideoDetailActivity");
                                    params.put("carrierName", CommonUtils.getOperator(VideoDetailActivity.this));
                                    avid = itemListad.get(i).getId();
                                    RouteUtils.adPlaylog(VideoDetailActivity.this, params);
                                }


                            } else if (time > itemListad.get(i).getEndTime()) {
                                re_header_ad_2.setVisibility(View.GONE);
                            }

                        } else if ("left".equals(itemListad.get(i).getPosition())) {
                            if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                                re_header_ad_1.setVisibility(View.VISIBLE);
                                GlideApp.with(VideoDetailActivity.this)
                                        .load(itemListad.get(i).getImgs().get(0))
                                        .override((int) (itemListad.get(i).getWidth() * density), (int) (itemListad.get(i).getHeight() * density))
//                                    .override(360,150)
                                        .into(iv_video_header_ad_1);
                                if (avid.equals(itemListad.get(i).getId())) {

                                } else {
                                    Map<String, String> params = new HashMap<>();
                                    params.put("articleId", id);
                                    params.put("advid", itemListad.get(i).getId());
                                    params.put("pageName", "VideoDetailActivity");
                                    params.put("carrierName", CommonUtils.getOperator(VideoDetailActivity.this));
                                    avid = itemListad.get(i).getId();
                                    RouteUtils.adPlaylog(VideoDetailActivity.this, params);
                                }
                            } else if (time > itemListad.get(i).getEndTime()) {
                                re_header_ad_1.setVisibility(View.GONE);
                            }

                        } else if ("right".equals(itemListad.get(i).getPosition())) {
                            if (time >= itemListad.get(i).getStartTime() && time <= itemListad.get(i).getEndTime()) {
                                re_header_ad_3.setVisibility(View.VISIBLE);
                                GlideApp.with(VideoDetailActivity.this)
                                        .load(itemListad.get(i).getImgs().get(0))
                                        .override((int) (itemListad.get(i).getWidth() * density), (int) (itemListad.get(i).getHeight() * density))
                                        .into(iv_video_header_ad_3);
                                if (avid.equals(itemListad.get(i).getId())) {

                                } else {
                                    Map<String, String> params = new HashMap<>();
                                    params.put("articleId", id);
                                    params.put("advid", itemListad.get(i).getId());
                                    params.put("pageName", "VideoDetailActivity");
                                    params.put("carrierName", CommonUtils.getOperator(VideoDetailActivity.this));
                                    avid = itemListad.get(i).getId();
                                    RouteUtils.adPlaylog(VideoDetailActivity.this, params);
                                }
                            } else if (time > itemListad.get(i).getEndTime()) {
                                re_header_ad_3.setVisibility(View.GONE);
                            }

                        }


                    }
                } catch (Exception e) {
                }

                break;

            default:
                break;
        }


    }

    /**
     * 取消收藏
     */
    public void getDeleteCollectActicles(String vid) {

        Map<String, String> headers = new HashMap<>();
        headers.put("Content-Type", "application/x-www-form-urlencoded");
        headers.put("Authorization", SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_TOKEN));
        String url = NetConfig.APPUSER__DELETE_COLLECTARTICLES
                + "/" + SharepUtils.getString_info(VideoDetailActivity.this, SharepUtils.USER_LOGIN_USERID)
                + "/collection/" + vid;

        OkHttpUtils.delete()
                .url(url)
                .headers(headers)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {


                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Gson gson = new Gson();

                        GsonResultok packlist = gson.fromJson(response, GsonResultok.class);
                        int code = packlist.getCode();
                        if (code == 200) {
                            iv_video_sc.setImageResource(R.drawable.iv_video_sc);
                            is_sc = false;
                            SharepUtils.setString_info(VideoDetailActivity.this, "0", SharepUtils.IS_SC);
                            tv_video_sc.setText("收藏");
                        }
                    }
                });
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        updatePlayerViewMode();
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        //解决某些手机上锁屏之后会出现标题栏的问题。
        updatePlayerViewMode();
    }

    private void updatePlayerViewMode() {
        if (mAliyunVodPlayerView != null) {
            int orientation = getResources().getConfiguration().orientation;
            if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                //转为竖屏了。
                this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                mAliyunVodPlayerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

                //设置view的布局，宽高之类
                RelativeLayout.LayoutParams aliVcVideoViewLayoutParams = (RelativeLayout.LayoutParams) mAliyunVodPlayerView
                        .getLayoutParams();
                aliVcVideoViewLayoutParams.height = (int) (ScreenUtils.getWidth(this) * 9.0f / 16);
                aliVcVideoViewLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
                mRecyclerView.setVisibility(View.VISIBLE);
                li_ad.setVisibility(View.VISIBLE);


            } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                //转到横屏了。
                //隐藏状态栏
                this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
                mAliyunVodPlayerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                //设置view的布局，宽高
                RelativeLayout.LayoutParams aliVcVideoViewLayoutParams = (RelativeLayout.LayoutParams) mAliyunVodPlayerView
                        .getLayoutParams();
                aliVcVideoViewLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
                aliVcVideoViewLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
                mRecyclerView.setVisibility(View.GONE);
                li_ad.setVisibility(View.GONE);

            }

        }
    }

}
